package com.brush.brushsysapi.controller;


import com.brush.brushcommon.dto.Result;
import com.brush.brushsysapi.service.FileUploadService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.UUID;

@Tag(name ="文件上传")
@RestController
//@RequestMapping(value="/fileUpload",produces = "application/json;charset=UTF-8")
@RequestMapping("/upload")
@Log4j2(topic = "business")
public class UploadController {


    @Resource
    FileUploadService fileUploadService;


//    @ResponseBody
    @PostMapping("/file")
    @Operation(summary ="上传文件")
    public Result sendVerificationCode(@RequestParam(value="file") MultipartFile[] myFiles) {
        try {
            return fileUploadService.uploadFile(myFiles);
        } catch (Exception e) {
            log.error("catch Exception",e);
            return Result.fail(500,e.getMessage());
        }
    }

}
